#include "include/ui_task.h"

Aix_data A1_data;
void positon_control(){
	A1_data.ok=0;
	//int cntwrd,pos;
	printf("please input cntwrd and position(r/min)\n");
	scanf("%d %d",&A1_data.cntlwd,&A1_data.tarpos);
	printf("cntwrd:%d;position:%d\n",A1_data.cntlwd,A1_data.tarpos);
	
	while(!A1_data.ok){
		if(A1_data.ok){
			printf("status:%d;actpos:%d\n",A1_data.status,A1_data.actpos);
			break;
			A1_data.ok=0;
		}
	
	sleep(1);
	printf("wait data ok\n");
	
	}

}

void motor_enable(){
	
	do{
	A1_data.cntlwd=0x10;//enable operation
	sleep(0.1);
	A1_data.cntlwd=0x06;//shut down
	sleep(0.1);
	A1_data.cntlwd=0x07;//disable voltage,quik stop
	sleep(0.1);
	A1_data.cntlwd=0xf;// fault reset
	sleep(0.1);
	}
	while(!((A1_data.status& 0x06f) == 0x027));
	
	printf("enable servo success!\n");

}

void motor_disable(){
	
	do{
	A1_data.cntlwd=0x05;//disable operation
	sleep(0.1);
	A1_data.cntlwd=0x06;//shut down
	sleep(0.1);
	A1_data.cntlwd=0x07;//disable voltage,quik stop
	sleep(0.1);
	A1_data.cntlwd=0xf;//fault reset
	sleep(0.1);
	}
	while((A1_data.status& 0x06f) == 0x027);
	
	printf("disable servo success!\n");

}




